package czy.demo.util;

import org.springframework.stereotype.Component;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

@Component
public class MD5Util {

    private static MessageDigest digest = null;

    static{
        try{
            digest = MessageDigest.getInstance("MD5");
        }catch (NoSuchAlgorithmException ex){
            ex.printStackTrace();
        }
    }

    public String getMD5(String content){
        return new String(digest.digest(content.getBytes()));
    }

    public String getMD5(byte[] bytes){
        return new String(digest.digest(bytes));
    }

}
